<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
    <title>物业费管理</title>
    <meta name="decorator" content="default"/>
    <script type="text/javascript" src="${ctxStatic}/supcan/ajaxSet.js"></script>
    <script type="text/javascript" src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.min.js"></script>
    <script type="text/javascript" src="${ctxStatic}/jquery-validation/1.11.0/jquery.validate.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("#box").focus();
            $("#inputForm").validate({
                rules:{
                    mobile:{
                        required:true,
                    },
                    communityId:{
                        required:true,
                        communityId:"communityId"
                    }/*,
                    areas:{
                        required:true,
                        areas:"areas"
                    }*/
                },
                submitHandler: function(form){
                    if(isok!=2){
                        loading('正在提交，请稍等...');
                        form.submit();
                    }else{
                        document.getElementById("mm").innerHTML="联系电话已经存在！";
                    }

                },
                errorContainer: "#messageBox",
                errorPlacement: function(error, element) {
                    $("#messageBox").text("输入有误，请先更正。");
                    if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
                        error.appendTo(element.parent().parent());
                    } else {
                        error.insertAfter(element);
                    }
                }
            });
            $.validator.addMethod("communityId",function(values,elements){
                if(values=="请选择"){
                    document.getElementById("tt").innerHTML="请选择小区名称";
                    return false;
                }
                else{
                    document.getElementById("tt").innerHTML="*";
                    return true;
                }
            },"");
            $("#communityId").change(function(){
                document.getElementById("tt").innerHTML="*";
            });
           /* $.validator.addMethod("areas",function(values,elements){
                if(values=="请选择"){
                    document.getElementById("nn").innerHTML="请选择区域";
                    return false;
                }else{
                    document.getElementById("nn").innerHTML="*";
                    return true;
                }
            },"");
            $("#areas").change(function(){
                document.getElementById("nn").innerHTML="*";
            });*/
        });
    </script>
    <script>
        var isok=0;
        $(function() {
            //将省id传入后台
            $("#box").change(function() {
                var areasId = $("#box").val();
                $("#areaid").val($("#box option:selected").val());
                $("#area").val($("#box option:selected").text());
                $.ajax({
                    type : "POST",
                    url : "${ctx}/sys/office/showCommunityListByAreaId",
                    data : {
                        areasId : areasId
                    },
                    dataType : "JSON",
                    success : function(date) {
                        var str = "<option>请选择</option>";
                        $("#box1").html("");
                        for ( var i = 0; i < date.length; i++) {
                            str += "<option value='"+date[i].id+"'>" + date[i].name + "</option>";

                        }
                        $("#box1").append(str);


                    }
                });

            });
        });
    </script>
    <script>
        var isok=1;
        $(function(){
            $("#mobile").blur(function(){
                var mobile=$("#mobile").val();
                var mid=$("#mid").val();
                if(mobile==""){
                    document.getElementById("mm").innerHTML="请填写联系方式！";
                }else{
                    $.ajax({
                        type : "POST",
                        url : "${ctx}/sys/agentTenenment/checkSenderByMobile",
                        data : {
                            mobile:mobile,
                            id:mid
                        },
                        success : function(data) {
                            if(data=="false"){
                                document.getElementById("mm").innerHTML="联系电话已经存在！";
                                isok=2;
                            }else{
                                document.getElementById("mm").innerHTML="*";
                                isok=1;
                            }
                        }
                    });
                }

            });
        });

    </script>
</head>
<body>
<ul class="nav nav-tabs">
    <li><a href="${ctx}/sys/agentTenenment/agentTenementList">物业费列表</a></li>
    <li class="active"><a href="${ctx}/sys/agentTenenment/form?id=${tbUserTenementInfo.id}">物业费${not empty tbUserTenementInfo.id?'修改':'添加'}</a></li>
</ul><br/>
<form:form id="inputForm" modelAttribute="tbUserTenementInfo" action="${ctx}/sys/agentTenenment/saveTenement?" method="post" class="form-horizontal">
    <form:hidden path="id" id="mid"/>
    <sys:message content="${message}"/>
    <div class="control-group">
        <label class="control-label">区域名称:</label>
        <div class="controls">
					<span><!--${user.areas}-->
						<select id="box" name="areas" id="areas" class="input-medium">
							<option>请选择</option>
							<c:forEach items="${areasList}" var="areas">
                                   <c:choose>
                                        <c:when test="${community.areaId eq areas.areaid}">
                                            <option  value="${areas.areaid}" selected >${areas.area}</option>
                                        </c:when>
                                        <c:otherwise>
                                        <option  value="${areas.areaid}" >${areas.area}</option>
                                   </c:otherwise>
                                </c:choose>

                            </c:forEach>
						</select>
					</span>
            <span class="help-inline"><font color="red" id="nn">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">小区名称:</label>
        <div class="controls">
            <span>
				<select id="box1" name='communityId' class="input-medium">
					<option >请选择</option>
					<c:if test="${tbUserTenementInfo.id!=null}">
                        <option value="${community.id}" selected>${community.commName}</option>
                    </c:if>
				</select>
			</span>
            <span class="help-inline"><font color="red" id="tt">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">业主名称:</label>
        <div class="controls">
            <form:input path="name" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">联系电话:</label>
        <div class="controls">
            <form:input id="mobile" path="mobile" htmlEscape="false" maxlength="50"  class="phone"/>
            <span class="help-inline"><font color="red" id="mm">*</font> </span>
        </div>
    </div>
    <%--<div class="control-group">
        <label class="control-label">手机:</label>
        <div class="controls">
            <form:input id="mobilePhone" path="mobilePhone" htmlEscape="false" maxlength="50"  class="phone"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>--%>
    <div class="control-group">
        <label class="control-label">楼号:</label>
        <div class="controls">
            <form:input path="buildNum" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">单元号:</label>
        <div class="controls">
            <form:input path="unitNo" htmlEscape="false" type="number" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <%--<div class="control-group">
        <label class="control-label">楼层:</label>
        <div class="controls">
            <form:input path="floorNo" htmlEscape="false" type="number" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>--%>
    <div class="control-group">
        <label class="control-label">门牌:</label>
        <div class="controls">
            <form:input path="showName" htmlEscape="false" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">住户面积:</label>
        <div class="controls">
            <form:input path="coveredArea" htmlEscape="false" type="number" maxlength="50" class="required"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <div class="control-group">
        <label class="control-label">物业单价:</label>
        <div class="controls">
            <form:input path="propertyFee" htmlEscape="false" maxlength="50" class="required" type="number" min="0"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
   <%-- <div class="control-group">
        <label class="control-label">缴费金额:</label>
        <div class="controls">
            <input type="text" name="totalFee" <c:if test="${tbUserTenementInfo.id!=null}"> value="${tbUserTenementInfo.totalFee}"</c:if>/>
        </div>
    </div>--%>
    <div class="control-group">
        <label class="control-label">返消费缴费系数:</label>
        <div class="controls">
            <form:input path="buildingNo" htmlEscape="false" maxlength="50" class="required"  min="0"/>
            <span class="help-inline"><font color="red">*</font> </span>
        </div>
    </div>
    <%--<div class="control-group">
        <label class="control-label">返还消费金额:</label>
        <div class="controls">
            <input type="text" name="backFee" <c:if test="${tbUserTenementInfo.id!=null}"> value="${tbUserTenementInfo.backFee}"</c:if>/>
        </div>
    </div>--%>
    <div class="form-actions">
        <input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
        <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
    </div>
</form:form>
</body>
</html>